function createUserList() {
  return [
    {
      userId: 1,
      avatar: '/avatar.jpg',
      username: 'admin',
      password: '123456',
      desc: '平台管理员',
      roles: ['平台管理员'],
      routes: [
        {
          id: '1',
          path: 'home',
          component: '/home/index',
          name: 'home',
          title: '首页'
        },
        {
          id: '2',
          path: 'system',
          redirect: '/main/system/user',
          name: '/system',
          component: '/system/index',
          title: '系统管理',
          children: [
            {
              id: '1-1',
              path: 'user',
              component: '/system/user/index',
              name: 'user',
              title: '用户管理'
            },
            {
              id: '1-2',
              path: 'role',
              component: '/system/role/index',
              name: 'role',
              title: '角色管理'
            }
          ]
        }
      ],
      token: 'Admin Token'
    },
    {
      userId: 2,
      avatar: '',
      username: 'system',
      password: '123456',
      desc: '系统管理员',
      roles: ['系统管理员'],
      routes: ['system'],
      token: 'System Token'
    }
  ]
}
//获取用户信息
export default [
  {
    url: '/api/user/login',
    method: 'post',
    response: ({ body }) => {
      const { username, password } = body
      const checkUser = createUserList().find((item) => {
        return item.username === username && item.password === password
      })
      if (!checkUser) {
        return { code: 201, data: { message: '账号或密码不正确' } }
      }
      let { token } = checkUser
      return { code: 200, data: { token } }
    }
  },
  {
    url: '/api/user/userInfo',
    method: 'post',
    response: ({ body }) => {
      const { token } = body
      const checkUser = createUserList().find((item) => {
        return item.token === token
      })
      if (!checkUser) {
        return { code: 201, data: { message: 'token失效' } }
      }
      return { code: 200, data: { ...checkUser } }
    }
  }
]
